package com.example.admin.service;

import com.example.admin.common.Result;
import com.example.admin.entity.ElderBedInfo;
import com.example.admin.mapper.ElderBedMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ElderBedService {

    @Autowired
    private ElderBedMapper elderBedMapper;


    public List<ElderBedInfo> selectElderBedInfoPage() {

       List<ElderBedInfo> elderBedInfoList= elderBedMapper.selectElderBedInfoPage();
       return elderBedInfoList;
    }

    public Result deleteElderBedById(Integer id) {

       int count= elderBedMapper.deleteElderBedById(id);
       if(count==0){
           return Result.error("400","删除失败");
       }
       return Result.success("删除成功");
    }

    public Result addElderBeb(ElderBedInfo elderBedInfo) {

        int count=elderBedMapper.addElderBeb(elderBedInfo);
        if(count==0){
            return Result.error("400","新增失败");
        }
        return Result.success("新增成功");
    }

    public Result editeElderBed(ElderBedInfo elderBedInfo) {
        int count=elderBedMapper.editeElderBed(elderBedInfo);
        if(count==0){
            return Result.error("400","修改失败");
        }
        return Result.success("修改成功");
    }

    public List<ElderBedInfo> selectElderBedById(Integer elderId) {

      List<ElderBedInfo> elderBedInfoList=  elderBedMapper.selectElderBedById(elderId);
      return elderBedInfoList;
    }
}
